cmake_minimum_required(VERSION 3.17)

project(CHIP8_Simulator)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# 自动调用MOC,UIC,RCC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

##设置cmake所在目录
##set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_DIR}/$ENV{QT_VERSION}/gcc_64/lib/cmake)
#set(CMAKE_PREFIX_PATH D:/Qt/Qt5.12.10/5.12.10/mingw73_64)
## 找到对应的qt模块，名字为qmake中QT += <name>中的name首字母大写后加上Qt5前缀
## 例如core为QtCore，你也可以去${CMAKE_PREFIX_PATH}的目录中找到正确的模块名
## 如果不想使用系统qt，这样写（注意NO_DEFAULT_PATH参数，它会让find_package跳过系统目录的查找）：
#find_package(Qt5Widgets REQUIRED NO_DEFAULT_PATH)
## 如果你想要使用系统自带的qt，这样写：
## find_package(Qt5Widgets REQUIRED)
## 将当前目录的所有源文件添加进变量
#aux_source_directory(. DIRS_SRCS)
## 通常这样设置就可以，如果你的项目包含qrc文件，那么需要将它们单独添加进来
## 例如add_executable(CHIP8_Simulator ${DIRS_SRCS} resources.qrc)
#add_executable(CHIP8_Simulator ${DIRS_SRCS})
## 把对应Qt模块的库链接进程序
#target_link_libraries(CHIP8_Simulator Qt5::Widgets)



set(CMAKE_PREFIX_PATH D:/Qt/Qt5.12.10/5.12.10/mingw73_64) #这里需要填入自己安装的路径


#### FIND GLUT####
message(STATUS "FIND OpenGL")
set(GLUT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/3rdparty/freeglut/include)
set(GLUT_glut_LIBRARY ${PROJECT_SOURCE_DIR}/3rdparty/freeglut/lib/x64/freeglut.lib)
#你要是不知道变量的值那就打印出来
#实在不行就强行连接
message(STATUS "GLUT_glut_LIBRARY:${GLUT_glut_LIBRARY}")
include_directories(${GLUT_INCLUDE_DIR})

#### FIND OPENGL###
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
if( NOT OPENGL_FOUND)
    message(ERROR "OPENGL not found!")
endif(NOT OPENGL_FOUND)

find_package(Qt5Widgets REQUIRED)
find_package( Qt5Core)
find_package( Qt5Gui)


set(UI_FILES)

set(RC_FILES)

set(QRC_FILES)




# set(SOURCE_FILES main.cpp chip8.h chip8.cpp)
#add_executable(CHIP8_Simulator WIN32 ${RC_FILES}${SOURCE_FILES}${UI_FILES}${QRC_FILES} Monitor64x32.h Monitor64x32.cpp Monitor64x32GL.h Monitor64x32GL.cpp)
add_executable(CHIP8_Simulator main.cpp chip8.h chip8.cpp Monitor64x32.h Monitor64x32.cpp Monitor64x32GL.h Monitor64x32GL.cpp mainwindow.h  mainwindow.cpp mainwindow.ui)

 target_link_libraries(CHIP8_Simulator
         ${GLUT_glut_LIBRARY}
         ${OPENGL_LIBRARIES}
         )

qt5_use_modules(CHIP8_Simulator Core Widgets Gui OpenGL Network)

